package net.kansun.impl;

import net.kansun.Parser;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * A {@link Parser} implementation that parses irregular numbers to words.
 */
public abstract class AbstractIrregularParser implements Parser {

   /**
    * mappings between irregular numbers and the corresponding words.
    */
   private Map<Long, String> mappings = new HashMap<Long, String>();

   public void setMappings(Properties mappingProps) {

      if (null == mappings) {
         mappings = new HashMap<Long, String>();
      }

      for (Map.Entry<Object, Object> entry : mappingProps.entrySet()) {
         String key = entry.getKey().toString();
         String value = entry.getValue().toString();

         mappings.put(Long.valueOf(key), value);
      }
   }

   protected Map<Long, String> getMappings() {
      return this.mappings;
   }
}
